import { VuexModule, Module, Action, getModule, Mutation } from 'vuex-module-decorators'
import { commonAction, deepClone } from '@/utils/common'
import store from '@/store'
import { number } from 'echarts'

@Module({ dynamic: true, name: 'monitoring', store, namespaced: false })
class Monitoring extends VuexModule {
  @Action // 监听
  public listen (id) {
    return commonAction({ url: '/call/action/monitor/agent/listen', method: 'post', data: { agentNumber: id } }).then(res => res)
  }

  @Action // 耳语
  public whisper (id) {
    return commonAction({ url: '/call/action/monitor/agent/whisper', method: 'post', data: { agentNumber: id } }).then(res => res)
  }

  @Action // 强插
  public breakin (id) {
    return commonAction({ url: '/call/action/monitor/agent/breakin', method: 'post', data: { agentNumber: id } }).then(res => res)
  }

  @Action // 强拆(强行挂断)
  public hangup (id) {
    return commonAction({ url: '/call/action/monitor/agent/hangup', method: 'post', data: { agentNumber: id } }).then(res => res)
  }

  @Action // 强接
  public loot (id) {
    return commonAction({ url: '/call/action/monitor/agent/loot', method: 'post', data: { agentNumber: id } }).then(res => res)
  }

  @Action // 状态切换
  public status (obj) {
    const { id, status } = obj
    return commonAction({ url: '/call/action/monitor/agent/status', method: 'post', data: { agentNumber: id, statusNumber: status } }).then(res => res)
  }

  @Action // 签入
  public signin (obj) {
    const { id, status } = obj
    return commonAction({ url: '/call/action/monitor/agent/signin', method: 'post', data: { agentNumber: id, loginType: status } }).then(res => res)
  }

  @Action // 签出
  public signout (id) {
    return commonAction({ url: '/call/action/monitor/agent/signout', method: 'post', data: { agentNumber: id } }).then(res => res)
  }

  @Action // 批量签出
  public batchSignout (id) {
    return commonAction({ url: '/call/action/monitor/agent/batchSignout', method: 'post', data: { agentNumbers: id } }).then(res => res)
  }

  @Action // 技能组抢接
  public queueLoot (id) {
    return commonAction({ url: '/call/action/monitor/queue/loot', method: 'post', data: { superUniqueId: id } }).then(res => res)
  }

  @Action // 服务号抢接
  public trunkNumberLoot (id) {
    return commonAction({ url: '/call/action/monitor/trunkNumber/loot', method: 'post', data: { superUniqueId: id } }).then(res => res)
  }
}

export const MonitoringModule = getModule(Monitoring)
